package com.youchuang.service;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class HelloService {

    @Autowired
    RestTemplate restTemplate;

    @HystrixCommand(fallbackMethod = "serviceFailure")
    public String getPortContent() {
        return restTemplate.getForObject("http://EUREKA-CLIENT/port", String.class);
    }

    @HystrixCommand(fallbackMethod = "serviceFailure")
    public String getHelloContent() {
//        return restTemplate.getForObject("http://EUREKA-CLIENT/gitHello", String.class);
        return restTemplate.getForObject("http://EUREKA-CLIENT-BETA/port", String.class);
    }

    public String serviceFailure() {
        return "hello world service is not available !";
    }

}